<template>
  <div class="login mt-5">
    <h1>Login</h1>
    <div class="_form">
      <el-form status-icon ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="输入手机号">
          <el-input type="text" v-model="input1"></el-input>
        </el-form-item>
        <el-form-item label="确认密码">
          <el-input type="password" v-model="input2"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="btnlogin">提交</el-button>
          <el-button>重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      input1: "",
      input2: "",
    };
  },
  methods: {
    btnlogin() {
      this.$axios
        .get("/login/cellphone", {
          params: {
            phone: this.input1,
            password: this.input2,
          },
        })
        .then((res) => {
          console.log(res.data);
          let dataArr = [];
          dataArr.push(res.data.token);
          dataArr.push(res.data.profile.nickname);
          localStorage.setItem("data", JSON.stringify(dataArr));
          // //    console.log(res.data);
          setTimeout(() => {
              this.$router.push("/");
          }, 2000);
        });
    },
  },
};
</script>

<style lang="scss">
.login {
  text-align: center;
  ._form {
    width: 400px;
    margin: 0px auto;
    // margin: 50%;
  }
}
</style>
